package com.chinackts.auth.model;

import okhttp3.Cookie;

import java.io.Serializable;

/**
 * @author Lianhong
 * @since 2021/3/10
 */
public class CookieStore implements Serializable {

    private String name;
    private String value;
    private long expiresAt;
    private String domain;
    private String path;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public long getExpiresAt() {
        return expiresAt;
    }

    public void setExpiresAt(long expiresAt) {
        this.expiresAt = expiresAt;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public void convert(Cookie cookie) {
        this.name = cookie.name();
        this.value = cookie.value();
        this.expiresAt = cookie.expiresAt();
        this.domain = cookie.domain();
        this.path = cookie.path();
    }

    public Cookie convert() {
        return new Cookie.Builder()
                .name(this.name)
                .value(this.value)
                .expiresAt(this.expiresAt)
                .domain(this.domain)
                .path(this.path)
                .build();
    }
}
